﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Einstein.Utility
{
    /// <summary>
    /// 目标网络地址信息
    /// </summary>
    public struct T_NetIP
    {
        /// <summary>
        /// IP地址 array[0..3] of byte
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4, MarshalType = "byte")]
        public byte[] localip;

        /// <summary>
        /// 物理MAC地址 array[0..5] of byte
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
        public byte[] localHW;

        /// <summary>
        /// 默认网关 array[0..3] of byte
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
        public byte[] Defgw;

        /// <summary>
        /// 网络掩码 array[0..3] of byte
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
        public byte[] netmask;

        /// <summary>
        /// 机号 word
        /// </summary>
        public ushort EquNO;

    }

    #region 脱机

    /// <summary>
    /// 有效期结构体
    /// </summary>
    public struct TEndDate
    {
        /// <summary>
        /// 年后二位
        /// </summary>
        public int EndYear;
        /// <summary>
        /// 月
        /// </summary>
        public int EndMonth;
        /// <summary>
        /// 日
        /// </summary>
        public int EndDay;
    }

    /// <summary>
    /// 卡注册结构
    /// </summary>
    public struct TUserReg
    {
        /// <summary>
        /// 有效期
        /// </summary>
        public TEndDate EndDate;

        /// <summary>
        /// 卡号 array[0..10] of char
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
        public char[] CardID;

        /// <summary>
        /// 密码 array[0..10] of char
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
        public char[] PassWord;

        /// <summary>
        /// 人员类别
        /// </summary>
        public byte MCardGroupID;

        /// <summary>
        /// 设备时间组
        /// </summary>
        public byte EquTimeId;

        /// <summary>
        /// 可通行门参数 array[0..32] of Boolean
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 33)]
        public bool[] Acce;

    }

    /// <summary>
    /// 存储器参数
    /// </summary>
    public struct TFlashInfo
    {
        /// <summary>
        /// 大小
        /// </summary>
        public int Size;

        /// <summary>
        /// 扇区大小
        /// </summary>
        public int SecSize;

        /// <summary>
        /// 记录大小
        /// </summary>
        public byte RecSize;

        /// <summary>
        /// 记录数
        /// </summary>
        public int RecCnt;

        /// <summary>
        /// 注册记录大小
        /// </summary>
        public byte CardSize;

        /// <summary>
        /// 注册记录数
        /// </summary>
        public int CardCnt;
    }

    /// <summary>
    /// 门禁时间表中的段时间
    /// </summary>
    public struct TSecTime
    {
        /// <summary>
        /// 开始小时
        /// </summary>
        public byte BeginHour;

        /// <summary>
        /// 开始分钟
        /// </summary>
        public byte BeginMinute;

        /// <summary>
        /// 结束小时
        /// </summary>
        public byte EndHour;

        /// <summary>
        /// 结束分钟
        /// </summary>
        public byte EndMinute;
    }

    public struct TDayTime
    {
        /// <summary>
        /// 天 array[0..7] of TSecTime
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
        public TSecTime[] DayTime;
    }

    /// <summary>
    /// 一张表的结构  共8天每天8段  依次为星期日、星期一、星期二。。。。星期六、节假日
    /// </summary>
    public struct TDoorTimeGroup
    {
        /// <summary>
        /// Day: array[0..7] of TDayTime;
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
        public TDayTime[] Day;
    }

    #region 节假日

    /// <summary>
    /// 节日
    /// </summary>
    public struct THoliday
    {
        /// <summary>
        /// 月
        /// </summary>
        public byte Month;

        /// <summary>
        /// 天
        /// </summary>
        public byte Day;
    }

    /// <summary>
    /// 节假日表  共128个
    /// </summary>
    public struct THolidays
    {
        /// <summary>
        /// array[0..128] of THoliday
        /// </summary>
        public THoliday[] Holiday;
    }

    #endregion

    /// <summary>
    /// 出入口参数
    /// </summary>
    public struct TChannelParam
    {
        /// <summary>
        /// 卡加密码开门  为1有效
        /// </summary>
        public int CardAndPassWord;

        /// <summary>
        /// 独立密码开门
        /// </summary>
        public int UsePassWord;

        /// <summary>
        /// 开门按钮开门
        /// </summary>
        public int OpenButton;

        /// <summary>
        /// 当前出入口的读卡模式  0为单卡   1为多卡
        /// </summary>
        public int McardMode;

        /// <summary>
        /// 节假日时间控制
        /// </summary>
        public int Holidy;

        /// <summary>
        /// 参入反回转控制
        /// </summary>
        public int PASS_BACK;

        /// <summary>
        /// 出入口进出标志
        /// </summary>
        public int PASS_BACK_IO;

        /// <summary>
        /// 锁类别
        /// </summary>
        public int LockType;

        /// <summary>
        /// 联动控制1控制方式 0不动作 1开门 2关门3常开 
        /// </summary>
        public int Link1Action;

        /// <summary>
        /// 保留
        /// </summary>
        public int Link2Action;

        /// <summary>
        /// 电锁开启延时
        /// </summary>
        public int LockDelay;

        /// <summary>
        /// 多卡模式时的 第一个类别卡
        /// </summary>
        public byte Group1;

        /// <summary>
        /// 多卡模式时的 第一个类别卡的张数
        /// </summary>
        public byte Cnt1;

        /// <summary>
        /// 多卡模式时的 第二个类别卡
        /// </summary>
        public byte Group2;

        /// <summary>
        /// 多卡模式时的 第二个类别卡的张数
        /// </summary>
        public byte Cnt2;

        /// <summary>
        /// 多卡模式时的 第二个类别卡
        /// </summary>
        public byte Group3;

        /// <summary>
        /// 多卡模式时的 第二个类别卡的张数
        /// </summary>
        public byte Cnt3;

        /// <summary>
        /// 多卡模式时的 第二个类别卡
        /// </summary>
        public byte Group4;

        /// <summary>
        /// 多卡模式时的 第二个类别卡的张数
        /// </summary>
        public byte Cnt4;
    }

    /// <summary>
    /// 出入口报警控制参数
    /// </summary>
    public struct TChannelWarnParam
    {
        /// <summary>
        /// 门磁现场报警
        /// </summary>
        public byte Magnetism;

        /// <summary>
        /// TimeOutDoor
        /// </summary>
        public byte TimeOutDoor;

        /// <summary>
        /// 锁开、门未开报警
        /// </summary>
        public byte LockOpenAndDoorClose;

        /// <summary>
        /// Senser报警触发类型
        /// </summary>
        public byte SenserWarnType;

        /// <summary>
        /// senser现场报警功能
        /// </summary>
        public byte SenserWarn;

        /// <summary>
        /// 现场报警清除方式
        /// </summary>
        public byte WarnClearMode;

        /// <summary>
        /// 胁近码报警
        /// </summary>
        public byte Intimidate;

        /// <summary>
        /// 传感器延时报警
        /// </summary>
        public byte SenserDelayWarn;

        /// <summary>
        /// 联动输入1报警控制
        /// </summary>
        public byte LinkAgeWarn1;

        /// <summary>
        /// 联动输入2报警控制
        /// </summary>
        public byte LinkAgeWarn2;

    }

    /// <summary>
    /// 记录结构体
    /// </summary>
    public struct TRecord
    {
        /// <summary>
        /// 卡号 array[0..10] of char
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
        public char[] CardID;

        /// <summary>
        /// 日期 array[0..20] of char
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 21)]
        public char[] Date;

        /// <summary>
        /// 时间 array[0..20] of char
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 21)]
        public char[] Time;

        /// <summary>
        /// 记录类型
        /// </summary>
        public byte RecType;

        /// <summary>
        /// 出入口号
        /// </summary>
        public byte Channel;

    }

    /// <summary>
    /// 互锁结构体
    /// </summary>
    public struct TMutexLock
    {
        /// <summary>
        /// array[0..31] of boolean
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public bool[] MutexLock;
    }

    /// <summary>
    /// 设备状态字  1为出错  0为正常
    /// </summary>
    public struct TDeviceStatus
    {
        /// <summary>
        /// 内存
        /// </summary>
        public byte Ram;

        /// <summary>
        /// Flash
        /// </summary>
        public byte Flash;

        /// <summary>
        /// 参数
        /// </summary>
        public byte ParamCheck;

        /// <summary>
        /// 时钟
        /// </summary>
        public byte time;

        /// <summary>
        /// 记录指针
        /// </summary>
        public byte record_Point;

        /// <summary>
        /// 电池
        /// </summary>
        public byte battery;
    }

    /// <summary>
    /// 出入口时间组号
    /// </summary>
    public struct TChannelTimeGroup
    {
        /// <summary>
        /// 出入口号
        /// </summary>
        public int ChannelID;

        /// <summary>
        /// 时间组号 array[0..63] of integer
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
        public int[] DeptTimeID;
    }

    /// <summary>
    /// 出入口其它时间组
    /// </summary>
    public struct TChannelOtherTime
    {
        /// <summary>
        /// 出入口号
        /// </summary>
        public int ChannelID;

        /// <summary>
        /// 常开时间段
        /// </summary>
        public int AlwaysOpen;

        /// <summary>
        /// 首卡开门时间段
        /// </summary>
        public int FirstCardOpen;

        /// <summary>
        /// 常闭时间段
        /// </summary>
        public int AlwaysClose;
    }

    /// <summary>
    /// 所有记录数
    /// </summary>
    public struct TRecCountInfo
    {
        /// <summary>
        /// 设备当前已经存储刷卡和事件记录的数量
        /// </summary>
        public int current_record_count;

        /// <summary>
        /// 记录采集指针当前位置
        /// </summary>
        public int Already_Collect_record;

        /// <summary>
        /// 设备当前已经存储的用户注册资料数量
        /// </summary>
        public int card_registry;
    }

    #endregion

}
